package com.ss.demo.springbootdemo.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * 作者: MrZhangJR
 * 时间: 2021/11/3 11:50
 * 描述:
 */
@Aspect
@Component
public class LogAspect {

    public static final String format = "%s-%s-%s";

    @Pointcut("execution (* *..controller.*.find*(..))")
    public void query(){};

    @After("query()")
    public void findLog(JoinPoint jp) {
        String className = jp.getTarget().getClass().getName();
        String methodName = jp.getSignature().getName();
        System.out.println(" = 111");
        System.out.println(String.format(format, className, methodName, Arrays.toString(jp.getArgs())));
    }

}
